Skip to content

add multistore support with mage add store and mage add stores#43

Open
allrude wants to merge 1 commit intomainfrom
feature/multistore-support
Open

add multistore support with mage add store and mage add stores#43
allrude wants to merge 1 commit intomainfrom
feature/multistore-support

Conversation

@allrude
Copy link
Collaborator

@allrude allrude commented Feb 22, 2026

Adds interactive and batch workflows for creating Magento 2 store views under a Valet local development environment.

New commands:
mage add store — interactive: prompts for code, name, domain, locale;
creates the store view via dev/tools/create-store.php,
sets base URLs, updates .valet-env.php, and runs
valet link + valet secure in one step.
mage add stores — batch: reads dev/tools/stores.json and creates all
defined store views non-interactively; batches all
valet link calls then all valet secure calls to avoid
redundant nginx restarts.

stores.json schema (project-agnostic — domain derived from project name):
{
"stores": [
{ "code": "nl_nl", "name": "Dutch", "suffix": "nl", "locale": "nl_NL" }
]
}

Changes:
src/_multistore.sh (new)
- mage_valet_env_add_entry: appends a store entry to .valet-env.php using Python 3; skips duplicates safely.
- mage_add_store: single-store interactive flow with auto-lowercase of store code and input validation.
- mage_add_stores_from_file: batch flow; resolves stores.json from dev/tools/ -> project root -> mage bin dir; computes domain as - so stores.json is project-agnostic.

src/_setup.sh
- Removed hardcoded placeholder store-2 / default2 from mage_setup.
- mage_setup now scaffolds dev/tools/create-store.php and dev/tools/stores.json from the mage bin directory into every new project automatically.
- After scaffold, mage_setup prompts to run mage_add_stores_from_file if stores.json is non-empty (skippable with N).

src/_info.sh — added help entries for add store and add stores
src/_mage.sh — added dispatch cases for add store and add stores

Adds interactive and batch workflows for creating Magento 2 store views
under a Valet local development environment.

New commands:
  mage add store   — interactive: prompts for code, name, domain, locale;
                     creates the store view via dev/tools/create-store.php,
                     sets base URLs, updates .valet-env.php, and runs
                     valet link + valet secure in one step.
  mage add stores  — batch: reads dev/tools/stores.json and creates all
                     defined store views non-interactively; batches all
                     valet link calls then all valet secure calls to avoid
                     redundant nginx restarts.

stores.json schema (project-agnostic — domain derived from project name):
  {
    "stores": [
      { "code": "nl_nl", "name": "Dutch", "suffix": "nl", "locale": "nl_NL" }
    ]
  }

Changes:
  src/_multistore.sh (new)
    - mage_valet_env_add_entry: appends a store entry to .valet-env.php
      using Python 3; skips duplicates safely.
    - mage_add_store: single-store interactive flow with auto-lowercase
      of store code and input validation.
    - mage_add_stores_from_file: batch flow; resolves stores.json from
      dev/tools/ -> project root -> mage bin dir; computes domain as
      <project-name>-<suffix> so stores.json is project-agnostic.

  src/_setup.sh
    - Removed hardcoded placeholder store-2 / default2 from mage_setup.
    - mage_setup now scaffolds dev/tools/create-store.php and
      dev/tools/stores.json from the mage bin directory into every new
      project automatically.
    - After scaffold, mage_setup prompts to run mage_add_stores_from_file
      if stores.json is non-empty (skippable with N).

  src/_info.sh  — added help entries for `add store` and `add stores`
  src/_mage.sh  — added dispatch cases for `add store` and `add stores`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant